import { authGuard, guestGuard } from './config/router';
import AuthLogin from './page/auth/login.vue';
import AuthRegister from './page/auth/register.vue';
import Layout from './page/layout/layout.vue';
import Dashboard from './page/Dashboard.vue';

import ProfileInfo from './page/profile/info.vue';
import ProfileChangePassword from './page/profile/ChangePassword.vue';

import SystemBackup from './page/system/backup.vue';
import SystemUser from './page/system/user.vue';

import ArchiveCategory from  './page/archive/Category.vue';
import ArchiveArchive from  './page/archive/Archive.vue';
import ArchivePettern from  './page/archive/Pattern.vue';

const profile = [
  {
    path: 'info',
    name: '信息',
    component: ProfileInfo
  },
  {
    path: 'ChangePassword',
    name: '更改密码',
    component: ProfileChangePassword
  }

];

const system = [
  {
    path: 'user',
    name: '用户管理',
    icon: 'xinrenzhinan',
    component: SystemUser
  },
  {
    path: 'backup',
    name: '备份',
    component: SystemBackup
  }
];

const Archive = [
  {
    path: 'category',
    name: '分类管理',
    component: ArchiveCategory
  },
  {
    path: 'archive',
    name: '内容管理',
    component: ArchiveArchive
  },
  {
    path: 'pettern',
    name: '模型管理',
    component: ArchivePettern
  }
];
export const routers = [
  {
    path: '/profile',
    name: '个人中心',
    component: Layout,
    icon: 'xinrenzhinan',
    redirect: '/profile/info',
    children: profile
  },
  {
    path: '/archive',
    name: '内容管理',
    component: Layout,
    redirect: '/archive/category',
    icon: 'zujian',
    children: Archive
  },
  {
    path: '/system',
    name: '系统管理',
    component: Layout,
    redirect: '/system/user',
    icon: 'zujian',
    children: system
  }
];

export default (store) => {
  return [
    ...authGuard(
      [
        {
          path: '/',
          name: '首页',
          redirect: '/profile/info',
          component: Dashboard,
          children: routers
        }
      ], store),
    ...guestGuard([
      {
        path: '/Login',
        name: '登录',
        component: AuthLogin
      },
      {
        path: '/Register',
        name: '注册',
        component: AuthRegister
      },
      {
        path: '*', redirect: '/404', hidden: true
      }
    ], store)
  ];
};
